#include <stdio.h>
int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int min = 0, hour = 0;
    if (b > 0)
    {
        min += 60 - b;
        a++;
        b=0;
    }
    hour += c - a;
    min += d;
    while (min >= 60)
    {
        min -=60;
        hour++;
    }
printf("%d %d\n",hour,min);
    return 0;
}